package com.ktjy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.mapper.LostMapper;
import com.ktjy.pojo.Customer;
import com.ktjy.pojo.Lost;
import com.ktjy.service.ICustomerService;
import com.ktjy.service.ILostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-01-16
 */
@Service
public class LostServiceImpl extends ServiceImpl<LostMapper, Lost> implements ILostService {
    @Autowired
    ICustomerService iCustomerService;
    @Override
    public boolean update(Lost lost) {
        //修改流失预警信息
        boolean flag1=this.updateById(lost);
        //如果是确认流失，还需要修改客户的状态为流失状态
        boolean flag2=false;
        if("3".equals(lost.getLstStatus())){
            //根据客户编号，查询客户信息
            Customer customer=iCustomerService.getById(lost.getLstCustNo());
            //修改客户的状态
            customer.setCustStatus("2");
            //修改客户状态
            flag2=iCustomerService.updateById(customer);
        }
        return flag1 && flag2;
    }
}
